package com.wbk.lotterysystemuserservice.controller.admin;


import com.github.pagehelper.PageInfo;
import com.wbk.lotterysystemuserservice.controller.admin.biz.UserBiz;

import com.wbk.user.qo.UserBanQO;
import com.wbk.user.vo.UserExtVO;
import com.wbk.user.vo.UserVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import result.Result;


@Api
@RestController
@RequestMapping("/feign/admin/user")
public class UserController {

    @Autowired
    UserBiz userBiz;

    @ApiOperation(value = "用户列表接口", notes = "用户列表")
    @GetMapping("/userList")
    public Result<PageInfo> userList(@ApiParam(value = "当前页") @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                     @ApiParam(value = "每页的记录数") @RequestParam(value = "pageSize", defaultValue = "5") int pageSize,
                                     @ApiParam(value = "连续显示的页数") @RequestParam(value = "navigatePages", defaultValue = "5") int navigatePages) {
        return userBiz.userList(pageNum, pageSize, navigatePages);
    }

    @ApiOperation(value = "用户信息接口", notes = "用户信息")
    @GetMapping("/userDetail/{userNo}")
    public Result<UserExtVO> userDetail(@ApiParam(value = "用户编号", required = true) @PathVariable("userNo") Long userNo) {
        return userBiz.userDetail(userNo);
    }

    @ApiOperation(value = "封禁用户接口", notes = "封禁用户")
    @PostMapping("/userBan")
    public Result<String> userBan(@RequestBody UserBanQO userBanQO) {
        return userBiz.userBan(userBanQO);
    }

    @ApiOperation(value = "根据用户编号查找用户接口", notes = "根据用户编号查找用户")
    @GetMapping("/user/{userNo}")
    public Result<UserVO> user(@ApiParam(value = "用户编号", required = true) @PathVariable("userNo") Long userNo) {
        return userBiz.user(userNo);
    }

    @ApiOperation(value = "根据手机号查找用户接口", notes = "根据手机号查找用户")
    @GetMapping("/userByMobile/{mobile}")
    public Result<UserVO> userByMobile(@ApiParam(value = "手机号", required = true) @PathVariable("mobile") String mobile) {
        return userBiz.userByMobile(mobile);
    }
}
